import browser_cookie3

# 自动获取 Chrome 的 B 站 Cookie
cookies = browser_cookie3.chrome(domain_name="bilibili.com")

# 打印 Cookie 信息（可选）
for cookie in cookies:
    print(f"{cookie.name} = {cookie.value}")

# 保存为 cookies.txt 文件
with open("cookies.txt", "w") as f:
    for cookie in cookies:
        f.write(f"{cookie.domain}\tTRUE\t{cookie.path}\tFALSE\t{cookie.expires or 0}\t{cookie.name}\t{cookie.value}\n")

print("Cookie 已保存到 cookies.txt")
